if not CLIENT then return false end -- Clientside only :)

--[[
made by:
 ____ _______                    _
|  __|__   __|_  _ __   ____  __| |
 \ \    | |/ _ \| '_ \ / __ )/ _` |
 _\ \   | | (_) | | | | (___| (_| |
|____|  |_|\___/|_| |_|\__,_)\__,_|

]]

LuaPassword = {}
LuaPassword.Version = 1.1

function LuaPassword.Generate(cmd,ply,arg)

    local len = 0
    local name = ""
	local char = {}
	local header = {}
	local info1 = "No name specified!"
	local info2 = "No length specified - generating with 8 chars!"
	local pw = ""
	local oldfile = ""
	if file.Exists("password.txt") then
		oldfile = file.Read("password.txt").."\n"
	end

	if !arg[1] then
		print(info1)
		return
	else
		name = tostring(arg[1])
	end
	if !arg[2] then
		len = 8
		print(info2)
	else
		len = tonumber(arg[2])
	end
	
	for i = 1, len do
		char[i] = string.char(math.random(66,90))
		header[i] = "="
	end
	for i = 1, math.floor(len/3) do
		char[math.random(1,len)] = string.char(math.random(48,57))
	end
	
	pw = table.concat(char, "")
	print("===================="..table.concat(header,""))
	print("Generated Password: "..pw)
    print("===================="..table.concat(header,""))
    char = {}
    header = {}
    file.Write("password.txt",oldfile.."Name: "..name.."\nPassword: "..pw.."\n")
end
concommand.Add("lua_password",LuaPassword.Generate)